package com.bjwl.web.contrlller.admin;

import com.bjwl.pojo.Dbackup;
import com.bjwl.service.DbackupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletContext;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author: dzx
 * @Date:Create：in 2020/4/18 9:03
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/admin/backup")
public class DbackupController {

    @Autowired
    private DbackupService dbackupService;

    @RequestMapping("/findAllBackup")
    public String findAllBackup(Model model){
        List<Dbackup> dbackupList = dbackupService.findAllDbackup();
        model.addAttribute("dbackupList",dbackupList);
        return "main_oa/base-list";
    }

    @RequestMapping("/addBackup")
    public void addBackup(HttpServletResponse response) {
        Dbackup dbackup = new Dbackup();
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
        String format = df.format(new Date());
        try{
            dbackupService.addDbackup(format);
        } catch (InterruptedException e){
            e.printStackTrace();
        }
    }


}
